// pages/activity/create_activity/components/vote/vote.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    voteTime: [['总共', '每天'], [1, 2, 3, 4, 5]],  //投票次数
    voteTimeValue: [0, 0],
    awardArr: [],  //奖项设置
    awardValue: [0, 0, 0],
  },
  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached: function () {
      this.initData()
    },
    moved: function () { },
    detached: function () { },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    // 投票次数设置
    voteTimeChange(e) {
      this.setData({
        voteTimeValue: e.detail.value
      })
      let vote_way = 1
      if (this.data.voteTime[0][this.data.voteTimeValue[0]] === '总共') {
        vote_way == 2
      }
      const vote_time = this.data.voteTime[1][this.data.voteTimeValue[1]]
      this.triggerEvent('voteTimeChange', {
        params: {
          vote_way: vote_way,
          vote_time: vote_time
        }
      })
    },
    awardArrChange(e) {
      this.setData({
        awardValue: e.detail.value
      })
    },
    initData() {
      var arr = []
      for (var i = 1; i <= 100; i++) {
        arr.push(i)
      }
      var awardArr = [arr, arr, ['xxxx优惠卷', '1111优惠卷', '122优惠卷', '133优惠卷']]
      this.setData({
        awardArr: awardArr
      })
    }
  }
})
